package pchi.pchicamera.adapters;

import java.util.ArrayList;

import pchi.pchicamera.R;
import pchi.pchicamera.data.GridViewHolder;
import pchi.pchicamera.data.MyItemGirdviewHolder;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class EditorAdapter extends BaseAdapter {

	private Context context;
	// LayoutInflater inflater;
	private ArrayList<MyItemGirdviewHolder> mEffect;
	private LayoutInflater inflater;

	public EditorAdapter(Context _Context,
			ArrayList<MyItemGirdviewHolder> _mEffect) {
		super();
		this.context = _Context;
		this.mEffect = _mEffect;
		this.inflater = LayoutInflater.from(this.context);
	}

	@Override
	public int getCount() {
		return mEffect.size();
	}

	@Override
	public Object getItem(int position) {
		return mEffect.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View item, ViewGroup parent) {

		GridViewHolder holder;
		item = inflater.inflate(R.layout.grid_editor_item, null);
		holder = new GridViewHolder();
		TextView textView = (TextView) item.findViewById(R.id.grid_item_label);
		textView.setText(mEffect.get(position).getName());
		ImageView imageView = (ImageView) item
				.findViewById(R.id.grid_item_image);
		imageView.setImageResource(mEffect.get(position).getIcon());
		item.setTag(holder);
		return item;
	}

}
